/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Conexao;

import java.math.BigInteger;
import java.util.ArrayList;
import java.util.List;
import org.hibernate.Query;
import org.hibernate.Session;

/**
 *
 * @author francis.almeida
 */
public class ConsultaBD {
    
    
        
        public static Object SelecionarFrom(String sql) {

        Session session = HibernateUtil.getSession();
        Object obj = new Object();
        try {
            Query qr = session.createQuery("from " + sql);
            obj = qr.uniqueResult();

        } catch (Exception ex) {
        } finally {
            session.close();
        }

        return obj;

    }
    
    
    
        public static List<Object> ListaFrom(String sql) {

        Session session = HibernateUtil.getSession();
        List<Object> lista = new ArrayList<Object>();
        try {

            lista = session.createQuery("from " + sql).list();

        } catch (Exception ex) {
        } finally {
            session.close();
        }

        return lista;

    }
        
            
        public static List<Object> ListaSQL(String sql) {

        Session session = HibernateUtil.getSession();
        List<Object> lista = new ArrayList<Object>();
        try {

            lista = session.createSQLQuery(sql).list();

        } catch (Exception ex) {
        } finally {
            session.close();
        }

        return lista;

    }
        
        public static Object SelectSQL(String sql) {

        Session session = HibernateUtil.getSession();
        Object obj = new Object();
        try {

            Query qr = session.createQuery(sql);
            obj = qr.uniqueResult();

        } catch (Exception ex) {
        } finally {
            session.close();
        }

        return obj;

    }
   
    
}
